﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Devtm.ServiceModel.Configurations;
using System.ServiceModel.Discovery;
using System.ServiceModel.Channels;
using System.ServiceModel;
using Devtm.ServiceModel.Proxy;

namespace Devtm.ServiceModel.Discovery.Discovery
{
    public class ServiceDirectoriesClient : ServiceDirectories<System.ServiceModel.Discovery.DiscoveryEndpoint>
    {


        public ServiceDirectoriesClient()
        {

            foreach (ProbeElement item in LocatorSection.OptimistConfiguration.Probe)
                Add(item.GetEndpoint());

        }


        public ServiceDirectoriesClient(Uri endpoint)
            : this(new DiscoveryEndpoint(DiscoveryVersion.WSDiscovery11, System.ServiceModel.Discovery.ServiceDiscoveryMode.Managed, new NetTcpBinding(), new EndpointAddress(endpoint)))
        {

        }

        public ServiceDirectoriesClient(DiscoveryVersion version, Uri endpoint)
            : this(new DiscoveryEndpoint(version, System.ServiceModel.Discovery.ServiceDiscoveryMode.Managed, new NetTcpBinding(), new EndpointAddress(endpoint)))
        {

        }


        public ServiceDirectoriesClient(DiscoveryVersion version, Uri endpoint, Binding binding)
            : this(new DiscoveryEndpoint(version, System.ServiceModel.Discovery.ServiceDiscoveryMode.Managed, binding, new EndpointAddress(endpoint)))
        {            

        }

        public ServiceDirectoriesClient(DiscoveryEndpoint endpoint)
            : this()
        {
            Insert(0, endpoint);
        }



        public override Proxy.IServiceResolver EndpointResolver(ProxyConfiguration proxy)
        {
            Devtm.ServiceModel.Resolver.ServiceResolver r = new Resolver.ServiceResolver(proxy);
            return r;
        }


    }
}
